package com.gvfish.dao;

import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.gvfish.entity.Article;
import com.gvfish.entity.Category;

@Repository
public class CategoryDao extends CommonDao<Category,Long>{
	
	@Autowired
	private PersistenceManagerFactory persistenceManagerFactory;

	@Override
	public PersistenceManager getPersistenceManager() {
		return persistenceManagerFactory.getPersistenceManager();
	}
	@Override
	public Class<Category> getTClass() {
		return Category.class;
	}
	public void delAllArt(Long id){
		Category category = getById(id);
		for(Article art:category.getArticles()){
			getPersistenceManager().deletePersistent(art);
		}
	}

}
